package com.finalist.dao.impl;

import javax.persistence.FlushModeType;

import org.springframework.stereotype.Repository;

import com.finalist.dao.OpenUnionDao;
import com.finalist.entity.OpenUnion;
@Repository("openUnionDaoImpl")
public class OpenUnionDaoImpl extends BaseDaoImpl<OpenUnion, Long>  implements OpenUnionDao{

	
	@Override
	public OpenUnion findByopenId(String openId) {
		 if (openId == null)
	        {
	            return null;
	        }
	        String jpql = "select openunions from OpenUnion openunions where openunions.openId = :openId";
	        try
	        {
	            return entityManager.createQuery(jpql, OpenUnion.class).setFlushMode(FlushModeType.COMMIT).setParameter("openId", openId).getSingleResult();
	        }
	        catch (Exception e)
	        {
	            e.printStackTrace();
	            return null;
	        }
	}

}
